import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.Scanner;

/**
 * @author gao
 * @date 2025/10/20 8:22
 */

public class Solution {
    public int[] dailyTemperatures(int[] temperatures) {
        int n = temperatures.length;
        int[] answer = new int[n];
        Deque<Integer> stack = new ArrayDeque<>();

        for (int i = 0; i < n; i++) {
            // 如果当前温度大于栈顶元素对应的温度，则将栈顶元素出栈，并计算其与当前温度的差值
            while (!stack.isEmpty() && temperatures[i] > temperatures[stack.peek()]) {
                int prevIndex = stack.pop();
                answer[prevIndex] = i - prevIndex;
            }
            // 将当前索引入栈
            stack.push(i);
        }
        return answer;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNext()) {
            int n = in.nextInt();
            int[] temperature = new int[n];
            for (int i = 0; i < n; i++) {
                temperature[i] = in.nextInt();
            }
            Solution solution = new Solution();
            System.out.println(Arrays.toString(solution.dailyTemperatures(temperature)));
        }
    }
}